package jiuxing

type Msg1F struct {
	Tm         []byte
	Plug       byte
	Order      string
	UserID     string
	UserType   uint16
	GroupCode  string
	CtlMode    byte
	CtlParam   uint32
	ChargeMode byte
	StartMode  byte
	StartTime  []byte
	OptCode    string
	BillMode   byte
	// BillModeRate BillMode
}

func (msg *Msg1F) Encode() []byte {
	ret := make([]byte, 0)
	ret = append(ret, msg.Tm...)
	ret = append(ret, msg.Plug)
	ret = append(ret, String2ByteWithlen(msg.Order, 32)...)
	ret = append(ret, String2ByteWithlen(msg.UserID, 32)...)
	ret = append(ret, Int16ToBytes(int16(msg.UserType))...)
	ret = append(ret, String2ByteWithlen(msg.GroupCode, 32)...)
	ret = append(ret, msg.CtlMode)
	ret = append(ret, IntToBytes(int(msg.CtlParam))...)
	ret = append(ret, msg.ChargeMode)
	ret = append(ret, msg.StartMode)
	ret = append(ret, msg.StartTime...)
	ret = append(ret, String2ByteWithlen(msg.OptCode, 6)...)
	ret = append(ret, msg.BillMode)
	// if msg.BillMode != 1 {
	// 	ret = append(ret, msg.BillModeRate.Encode()...)
	// }

	return ret
}
